package com.blb.orderservice.client;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blb.orderservice.pojo.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 调用商品服务的客户端
 */
@FeignClient(value = "product-service",fallback = ProductServiceClientFackback.class)
public interface ProductServiceClient {

    @GetMapping("/product/{id}")
    ResponseEntity<Product> getProductById(@PathVariable Long id);

    @GetMapping("/products-page")
    ResponseEntity<Page<Product>> getProductPage(@RequestParam(required = false,defaultValue = "1")Long current,
                                                        @RequestParam(required = false,defaultValue = "5")Long size);
    @PostMapping("/product")
    ResponseEntity<Product> addProduct(@RequestBody Product product);

    @PutMapping("/product")
    ResponseEntity<Product> updateProduct(@RequestBody Product product);

    @DeleteMapping("/product/{id}")
    ResponseEntity<Long> deleteProduct(@PathVariable Long id);
}
